<style>
    
.container {
    display: flex;
    align-items: center; 
    gap: 15px; 
    padding: 20px; 
    background-color: #ffffff; 
    border-radius: 8px; 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); 
    transition: all 0.3s ease; 
}


input[readonly] {
    background-color: #f7f7f7; 
    border: 1px solid #dcdcdc; 
    padding: 10px; 
    border-radius: 4px; 
    font-size: 16px; 
    color: #333333; 
    transition: background-color 0.3s ease; 
}


.container:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); 
}


input[readonly]:hover {
    background-color: #eaeaea; 
}
#buttons {
    padding: 10px 20px; 
    background-color: #007bff; 
    color: white; 
    border: none; 
    border-radius: 4px; 
    font-size: 16px; 
    cursor: pointer; 
    transition: background-color 0.3s ease, transform 0.2s ease; 
}
</style>
    <div class="container">
        <label for="readonlyInput">分享链接:</label>
        <input type="text" id="readonlyInput" value="" readonly>
        <button id="buttons" onclick="coptin();" type="button">Copy</button>
    </div>
    <script>
        function fetchgetormake(getsid){
            const formData = new FormData();
            formData.append('exmatid', getsid);
            fetch('../exam/getshareurl.php', {
                method: 'POST',
                body: formData
            })
            .then(function (response) {
                return response.json();
            }).then(function (data) {
                if(data.status === 200){
                    var protocol = window.location.protocol;
                    var hostname = window.location.hostname;
                    var siteUrl = protocol + '//' + hostname + '/share-exams/?';
                    document.getElementById('readonlyInput').value = siteUrl+data.msg;
                }else{
                    document.getElementById('readonlyInput').value = '获取失败';
                }
            });
            }
            function coptin() {
    var input = document.getElementById('readonlyInput');
    input.select(); 
    input.setSelectionRange(0, 99999); 
    document.execCommand('copy'); 
    alert('链接已复制');
}
        const searchParams = new URLSearchParams(window.location.search);
        let abids = searchParams.get('cokkid');
        fetchgetormake(abids);
    </script>